package com.zllkj.mm.model.entity

import android.graphics.Bitmap
import android.graphics.Rect
import android.os.Parcel
import android.os.Parcelable
import com.previewlibrary.enitity.IThumbViewInfo

class GridImageViewBean() : IThumbViewInfo {
    private var url //图片地址
            : String? = null
    private var mBounds // 记录坐标
            : Rect? = null
    private var user = "用户字段"
    private var videoUrl: String? = null
    public var videoBitmap : Bitmap? = null;

    constructor(parcel: Parcel) : this() {
        url = parcel.readString()
        mBounds = parcel.readParcelable(Rect::class.java.classLoader)
        user = parcel.readString()
        videoUrl = parcel.readString()
        videoBitmap = parcel.readParcelable(Bitmap::class.java.classLoader)
    }

    fun UserViewInfo(url: String?) {
        this.url = url
    }

    fun UserViewInfo(videoUrl: String?, url: String?) {
        this.url = url
        this.videoUrl = videoUrl
    }

    fun getUser(): String? {
        return user
    }

    fun setUser(user: String) {
        this.user = user
    }

    override fun getUrl(): String? { //将你的图片地址字段返回
        return url
    }

    fun setUrl(url: String?) {
        this.url = url
    }

    override fun getBounds(): Rect? { //将你的图片显示坐标字段返回
        return mBounds
    }


    override fun getVideoUrl(): String? {
        return videoUrl
    }

    fun setBounds(bounds: Rect?) {
        mBounds = bounds
    }


    fun setVideoUrl(videoUrl: String?) {
        this.videoUrl = videoUrl
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(url)
        dest.writeParcelable(mBounds, flags)
        dest.writeString(user)
        dest.writeString(videoUrl)
        dest.writeParcelable(videoBitmap,flags)
    }

    protected fun UserViewInfo(`in`: Parcel) {
        url = `in`.readString()
        mBounds = `in`.readParcelable(Rect::class.java.classLoader)
        user = `in`.readString()
        videoUrl = `in`.readString()
        videoBitmap = `in`.readParcelable(Bitmap::class.java.classLoader)
    }

    companion object CREATOR : Parcelable.Creator<GridImageViewBean> {
        override fun createFromParcel(parcel: Parcel): GridImageViewBean {
            return GridImageViewBean(parcel)
        }

        override fun newArray(size: Int): Array<GridImageViewBean?> {
            return arrayOfNulls(size)
        }
    }

}